/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package zgame.bean;

import java.util.Vector;

/**
 *
 * @author truonggiang
 */
public class PhomInfo {
  //  private int[] cards = new int[] {-1, -1, -1, -1, -1,-1,-1,-1,-1};
    private Vector<Integer> cards;
	private int avaiIndex = 0;
	private int index;
	private boolean isVertical;
	public PhomInfo()
	{
		cards = new Vector<Integer>();
	}
	public boolean isVertical() {
		return isVertical;
	}

	public void setVertical(boolean isVertical) {
		this.isVertical = isVertical;
	}

	public int size() {
		return cards.size();
	}
//	public int[] getCards()
//	{
//		return cards;
//	}
//	public int getSize()
//	{
//		return avaiIndex;
//	}
	public int getCard(int index) {
		return cards.get(index);
	}
	public boolean contains(int cardId)
	{
		return cards.contains(cardId);
	}
	public Vector<Integer> getCards()
	{
		return cards;
	}
//	public int nextCard() {
//		index++;
//		if (index < avaiIndex) {
//			return cards[index - 1];
//		} else {
//			index = 0;
//			return -1;
//		}
//	}

	public void addCard(int card) {
		cards.addElement(card);
	}
	
	public void removeCard(int card)
	{
		if(cards.contains(card))
		{
			cards.removeElement(card);
		}
	}
//	public void addCard(Object card)
//	{
//		if(avaiIndex < cards.length)
//		{
//			cards[avaiIndex] = (Integer)card;
//			avaiIndex++;
//		}
//	}
	public String toString() {
		String str = ":";
		for (int i = 0; i < size(); i++) {
            int temp = getCard(i);
            if(temp < 10)
            {
            	str += "0" + String.valueOf(temp);
            }
            else
            {
                str += String.valueOf(temp);
            }
		}
		return str;
	}
	public int getTotalPoint()
	{
		int total = 0;
		for(int i=0;i < avaiIndex;i++)
		{
			total += cards.get(i)%13 +1 ;
		}
		return total;
	}
	public boolean isMiddle(int card)
	{
		boolean greater=false,less=false;
		if(cards.contains(card))
		{
			for(int i=0;i < cards.size();i++)
			{
				if(card > cards.get(i))
				{
					greater = true;
					break;
				}
			}
			
			for(int i=0;i < cards.size();i++)
			{
				if(card < cards.get(i))
				{
					less = true;
					break;
				}
			}
			if(greater&&less)
			{
				return true;
			}
			else return false;
		}
		else return false;
			
	}
}
